from typing import Optional
from pydantic import BaseModel, Field, ConfigDict
from pydantic.types import UUID4
from datetime import datetime
from app.schemas.archivable import Archivable

# 基础模型
class ModelTrainingBase(BaseModel):
    model_version: Optional[str] = Field(description="模型版本")
    training_text: Optional[str] = Field(description="训练文本")
    training_voiceprint: Optional[str] = Field(description="训练语音")
    text_accuracy: Optional[float] = Field(description="文本准确度")
    sentence_accuracy: Optional[float] = Field(description="句子准确度")
    core_word_accuracy: Optional[float] = Field(description="核心词准确度")
    long_text_accuracy: Optional[float] = Field(description="长文本准确度")
    realtime_wer: Optional[float] = Field(description="实时WER(词错误率)")
    recognize_text: Optional[str] = Field(description="识别文本")
    comprehensive_accuracy: Optional[float] = Field(description="综合准确度")
    upload_file_path: Optional[str] = Field(description="训练素材上传路径")

# 创建时的数据模型
class ModelTrainingCreate(ModelTrainingBase):
    pass

# 更新时的数据模型
class ModelTrainingUpdate(ModelTrainingBase):
    pass

# 数据库基础模型
class ModelTrainingInDBBase(ModelTrainingBase, Archivable):
    model_config = ConfigDict(from_attributes=True)
    id: UUID4


# 返回给客户端的数据模型
class ModelTraining(ModelTrainingInDBBase):
    pass

# 数据库存储的数据模型
class ModelTrainingInDB(ModelTrainingInDBBase):
    user_id: Optional[UUID4]